package com.gitee.cheungming.consumer.controller;

import com.gitee.cheungming.common.Result;
import com.gitee.cheungming.consumer.model.Consumer;
import com.gitee.cheungming.consumer.service.IConsumerService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Zhang Ming
 * @since 2025-10-27
 */
@RestController
@RequestMapping("/consumer")
public class ConsumerController {


    @Resource
    IConsumerService consumerService;

    @RequestMapping("/login")
    public Result<String> login(@RequestBody Consumer consumer) {
        return Result.success();
    }

    @RequestMapping("/register")
    public Result<String> register(@RequestBody Consumer consumer) {
        consumerService.save(consumer);
        return Result.success();
    }

    /**
     * 使用积分支付
     */
    @RequestMapping("/payByScore")
    public Result<?> payByScore(@RequestParam Long consumerId,
                                @RequestParam Long score) {
        consumerService.payByScore(consumerId, score);
        return Result.success();
    }
}
